package com.burstly.lib.network.request;

import android.graphics.Bitmap;
import com.burstly.lib.constants.Constants;
import com.burstly.lib.persistance.IResourse;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;
import com.burstly.lib.util.Utils.DebugWrapper;

public class ImageFetchTask extends SafeAsyncTask<Bitmap>
{
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = "ImageFetchTask";
  private IResourse<Bitmap> mCache;
  private final IRequestCallback<Bitmap> mCallback;
  private final Utils.DebugWrapper mDebugger;
  private float mScale = 1.0F;

  public ImageFetchTask(String paramString, IRequestCallback<Bitmap> paramIRequestCallback)
  {
    setHost(paramString);
    this.mCallback = paramIRequestCallback;
    this.mDebugger = Utils.DebugWrapper.getDebugger("ImageFetchTask");
  }

  private Bitmap scaleImage(Bitmap paramBitmap)
  {
    if (paramBitmap == null)
      return null;
    return Bitmap.createScaledBitmap(paramBitmap, (int)(this.mScale * paramBitmap.getWidth()), (int)(this.mScale * paramBitmap.getHeight()), true);
  }

  public float getScale()
  {
    return this.mScale;
  }

  protected void onPostExecute(Bitmap paramBitmap)
  {
    super.onPostExecute(paramBitmap);
    if (Constants.IS_DEBUG_MODE)
    {
      LOG.logDebug("ImageFetchTask", "Memory state after loading image:", new Object[0]);
      this.mDebugger.logAll();
    }
    if (this.mCallback != null)
    {
      if (paramBitmap != null)
        this.mCallback.onSuccessUi(paramBitmap);
    }
    else
      return;
    this.mCallback.onFailUi(null);
  }

  protected Bitmap performInBackground()
  {
    super.performInBackground();
    if (!RequestManager.isOnline())
      return null;
    if (Constants.IS_DEBUG_MODE)
    {
      LOG.logDebug("ImageFetchTask", "Memory state before loading image:", new Object[0]);
      this.mDebugger.logAll();
    }
    if (this.mCache != null)
      return scaleImage((Bitmap)this.mCache.getResource(getHost()));
    return scaleImage(Utils.getBitmapByUrl(getHost()));
  }

  public void setCache(IResourse<Bitmap> paramIResourse)
  {
    this.mCache = paramIResourse;
  }

  public void setScale(float paramFloat)
  {
    this.mScale = paramFloat;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.network.request.ImageFetchTask
 * JD-Core Version:    0.6.2
 */